home *** CD-ROM | disk | FTP | other *** search
- package Common.ParticleSystem
- {
- import flash.display.MovieClip;
- import flash.display.Sprite;
-
- public class Effect extends Sprite
- {
-
-
- private var active:Boolean = false;
-
- private var disposable:Boolean = true;
-
- private var emitter:Array;
-
- private var parentNode:MovieClip;
-
- public function Effect()
- {
- emitter = new Array();
- active = false;
- disposable = true;
- super();
- }
-
- public static function fromXML(param1:XML) : Effect
- {
- var newEffect:Effect = null;
- var node:XML = null;
- var currentEmitter:Emitter = null;
- var xml:XML = param1;
- newEffect = new Effect();
- try
- {
- for each(node in xml.Emitter)
- {
- currentEmitter = Emitter.fromXML(node);
- newEffect.emitter.push(currentEmitter);
- newEffect.addChild(currentEmitter);
- }
- }
- catch(e:TypeError)
- {
- trace("Could not parse text into XML");
- trace(e.message);
- }
- return newEffect;
- }
-
- public static function clone(param1:Effect) : Effect
- {
- var _loc2_:Effect = null;
- var _loc3_:* = undefined;
- _loc2_ = new Effect();
- _loc3_ = param1.emitter.length;
- while(--_loc3_ != -1)
- {
- _loc2_.emitter[_loc3_] = Emitter.clone(param1.emitter[_loc3_]);
- _loc2_.addChild(_loc2_.emitter[_loc3_]);
- }
- return _loc2_;
- }
-
- public function set Disposable(param1:Boolean) : *
- {
- disposable = param1;
- }
-
- public function startEmission(param1:MovieClip, param2:uint) : void
- {
- var _loc3_:int = 0;
- _loc3_ = 0;
- while(_loc3_ < emitter.length)
- {
- emitter[_loc3_].startEmission();
- _loc3_++;
- }
- active = true;
- parentNode = param1;
- param1.addChild(this);
- mouseEnabled = false;
- }
-
- public function get Active() : Boolean
- {
- return active;
- }
-
- public function setPoint(param1:Number, param2:Number, param3:Boolean = true) : void
- {
- var _loc4_:int = 0;
- _loc4_ = 0;
- while(_loc4_ < emitter.length)
- {
- if(param3)
- {
- emitter[_loc4_].PointA.x = param1;
- emitter[_loc4_].PointA.y = param2;
- }
- else
- {
- emitter[_loc4_].PointB.x = param1;
- emitter[_loc4_].PointB.y = param2;
- }
- _loc4_++;
- }
- }
-
- public function stopEmission() : *
- {
- var _loc1_:int = 0;
- if(parentNode != null && parent == parentNode)
- {
- _loc1_ = 0;
- while(_loc1_ < emitter.length)
- {
- emitter[_loc1_].stopEmission();
- _loc1_++;
- }
- parentNode.removeChild(this);
- }
- }
-
- public function update() : void
- {
- var _loc1_:int = 0;
- if(!active)
- {
- stopEmission();
- return;
- }
- active = false;
- _loc1_ = 0;
- while(_loc1_ < emitter.length)
- {
- emitter[_loc1_].update();
- active = active || Boolean(emitter[_loc1_].Active);
- _loc1_++;
- }
- }
- }
- }
-